import java.util.Scanner;
import java.lang.Math;
import java.lang.String;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2022-07-28
 * Time: 16:28
 */
public class Test1_0728 {
    //获取一个数二进制序列中所有的偶数位和奇数位， 分别输出二进制序列
    public static void main10(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println("奇数位位：");
        for (int i = 30; i >= 0; i -= 2) {
            System.out.print(((n >> i) & 1)+" ");
        }
        System.out.println("\n");
        System.out.println("偶数位为：");
        for (int j = 31; j >= 1; j -= 2) {
            System.out.print(((n >> j) & 1)+" ");
        }
    }

    //编写代码模拟三次密码输入的场景。 最多能输入三次密码
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String password = "995520";
        System.out.println("只有三次机会");
        for (int i = 0; i < 3; i++) {
            System.out.println("请输入密码：");
            String input = scanner.nextLine();
            if (password.equals(input)) {
                System.out.println("密码正确");
                break;
            } else {
                if (i == 2) {
                    System.out.println("三次输入均错误，退出登录");
                    break;
                }
                System.out.println("密码错误你还有：" + (2 - i) + "次机会");
            }

        }
    }


    //输出一个整数的每一位，如：123的每一位是3，2，1
    public static void main8(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        while (n != 0) {
            System.out.print(n % 10+" ");
            n /= 10;
        }
    }

    //输出n*n的乘法口诀表，n由用户输入
    public static void main7(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个整数：");
        int n = scanner.nextInt();
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(i * j + " ");
            }
            System.out.println("\n");
        }
    }

    //多组输入打印X图形
    public static void main6(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int n = scanner.nextInt();
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (i == j || j + i == n - 1) {
                        System.out.print("*");
                    } else {
                        System.out.print(" ");
                    }
                }
                System.out.print("\n");
            }
        }
    }

    //打印X图形
    public static void main5(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if(i==j||j+i==n-1){
                    System.out.print("*");
                }else{
                    System.out.print(" ");
                }
            }
            System.out.println("\n");
        }
    }
    //100-1000的水仙花数
    public static void main4(String[] args) {
        int a, b, c = 0;
        for (int i = 100; i < 1000; i++) {
            a = i / 100; //获取百位
            b = (i / 10) % 10;
            c = i % 10;
            if (i == Math.pow(a, 3) + Math.pow(b, 3) + Math.pow(c, 3)) {
                System.out.println("该数为水仙花数" + i);
            }
        }
    }
    //计算1/1 -1/2 + 1/3 -1/4 + 1/5 …… + 1/99 - 1/100 的值
    public static void main3(String[] args) {
        float sum = 0f;
        int flag = 1;
        for (int i = 1; i <= 99; i++) {
            sum += (flag * Math.pow(i, -1));
            flag *= -1;
        }
        System.out.println(sum);
    }
    //求一个整数，在内存当中存储时，二进制1的个数
    public static void main2(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int i = 0;    //5 -  0101
        int count = 0;
        while (i < 32) {
            if (((a >> i) & 1) == 1) {
                count++;
            }
            i++;
        }
        System.out.println("该数得二进制一共有" + count + "个1");
    }
    //Scanner 得使用
    public static void main1(String[] args) {
        Scanner scanner= new Scanner(System.in);

        //优先输入字符串
        System.out.println("请输入你得名字");
        String name=scanner.nextLine(); //从键盘上读取一整行
        System.out.println("名字为"+name);

        System.out.println("请输入你得名字");
        String name1=scanner.next();  //读取到空格就停止 后面得内容不会继续读取，并且会把空格后面得东西交给下一个输入数
        System.out.println("名字为："+name1);
        //例如 zhang jing 只读取到zhang

        System.out.println("请输入年龄");
        int age=scanner.nextInt();
        System.out.println("年龄为"+age);

        System.out.println("请输入你的薪资");
        float meony=scanner.nextFloat();
        System.out.println("工资"+meony);

        //多组输入
        while(scanner.hasNextInt()){
            System.out.println("请输入年龄：");
            int age2=scanner.nextInt();
            System.out.println("年龄为："+age2);

            scanner.close();  //关闭资源

        }

    }
}
